package com.awenhui.demo.service.impl;

import com.awenhui.demo.dao.SysUserMapper;
import com.awenhui.demo.model.entity.SysUserEntity;
import com.awenhui.demo.service.SysUserService;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Random;

/**
 * @author yuxf
 * @version 1.0
 * @date 2021/4/16 11:51
 */
@Service
@DS("slave_1")//指定数据源
public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUserEntity> implements SysUserService {


        public SysUserEntity testGetOne(String userName)
        {
            SysUserEntity user = getOne(Wrappers.<SysUserEntity>lambdaQuery().eq(SysUserEntity::getUserName, userName));
            return user;
        }


        public void test()
        {
            //添加
            SysUserEntity userEntity=new SysUserEntity();
            userEntity.setUserName("yuxf");
            userEntity.setPassword(new Random().nextInt(999999)+"");

            save(userEntity);
        }

}
